home *** CD-ROM | disk | FTP | other *** search
/ Delphi Programmer's Power Pack / Delphi Volume 1.iso / s_to_z / subdatab / subdatab.int < prev    next >
Text File  |  1996-09-15  |  5KB  |  147 lines

  1. {
  2.   TSUBDataBase = class(TComponent)
  3.   A Database as Component
  4.  
  5.   Siegfried Unterbarnscheidt
  6.   Ricarda-Huch-Str. 12
  7.   50858 K÷ln  (GERMANY)
  8.   Compuserve-ID 101365,321
  9. }
  10.  
  11.  
  12.  
  13. unit Subdatab;
  14.  
  15. interface
  16.  
  17. uses
  18.   SysUtils, WinTypes, WinProcs, Classes,Controls,
  19.   Dialogs,Dsgnintf,FileCtrl,
  20.  
  21.   Subdata1,
  22.   Subdata2,
  23.   Subdata4,
  24.   Subdata5,
  25.   Subdata6;
  26.  
  27.  
  28.  
  29. Type
  30.   ESUBDBError = class(Exception)   {defined in subdata4!}
  31.   public
  32.     ErrorCode: longint;
  33.     constructor Create(pErrorCode: longint;const Message: string);
  34.   end;
  35.  
  36.   ESUBDBDuplicateIndexName = class(ESUBDBError);
  37.  
  38.   ESUBDBDuplicateIndex = class(ESUBDBError);
  39.  
  40.  
  41.  
  42. Type
  43.   TReorgEvent = procedure(Sender: TObject; ReorgAct :longint) of object;
  44.  
  45.  
  46. type
  47.   TSUBDataBase = class(TComponent)
  48.   private
  49.     { Private-Deklarationen }
  50.     {...}
  51.   protected
  52.     { Protected-Deklarationen }
  53.   public
  54.     { Public-Deklarationen }
  55.     constructor Create(AOwner: TComponent); override;
  56.     destructor  Destroy; override;
  57.     {adminstration}
  58.     procedure   Open; {by default the database opens automaticly}
  59.     procedure   Close;
  60.     procedure   Reorganisation;
  61.     Function    createIndex (Const AName : String;
  62.                               pKeyLaenge : byte;        {max 63}
  63.                               pdupl:boolean) : Boolean; {duplicate allowed?}
  64.     procedure DestroySUBFile;      {simply delete the file! Attention}
  65.  
  66.     {Indexkennstr is the "Name" of the index create by Createindex!}
  67.     {Index-Routinen}
  68.     Function    CountKeys( Const IndexKennStr: String ) : Longint;
  69.     Function    CountKeysLoHigh( Const IndexKennStr: String; loS,HiS : String ) : Longint;
  70.     Function    GetPositionforKey( const IndexKennStr: String;
  71.                                           loS,SearchKey : KeyType; id : longint ) : Longint;
  72.         {loS = Starting with
  73.          KeyType = String[63] or keylaenge defined in createIndex}
  74.     Function    NextIndex (Const IndexKennStr: String;
  75.                            SuchSchluessel : KeyType ): String;
  76.     Function    PrevIndex (Const IndexKennStr: String;
  77.                            SuchSchluessel : KeyType ): String;
  78.  
  79.     Function    FirstLoIndex (Const IndexKennStr: String; SuchSchl : KeyType ): String;
  80.  
  81.     Function    FirstIndex (const IndexKennStr: String ): KeyType;
  82.     Function    LastIndex (Const IndexKennStr: String ): KeyType;
  83.  
  84.  
  85.     {Data-Routinen:}
  86.     procedure   ReadActData (  laenge : longint; var Data );
  87.                 { first, last, next, prev Index you can
  88.                   directly read the data}
  89.     Function    UpdateDataWithID  ( ID : longint;NewDataSize  : longint; var theData ) : Boolean;
  90.     Function    DeleteDataWithID  ( ID : longint ) : Boolean;
  91.  
  92.  
  93.     {data and Index-Routinen}
  94.     procedure   addData_Indexe (Const IndexKennStr: array of Const;
  95.                                 Const IndexStr: array of Const;
  96.                                 laenge : longint; var Data );
  97.     {adding Data and all Index-Entryies with the data}
  98.  
  99.     procedure   UpdateData_Indexe (Const IndexKennStr: array of Const;
  100.                                    Const IndexStrOld: array of Const;
  101.                                    Const IndexStrNew: array of Const;
  102.                                          id : longint;
  103.                                          newDataSize : longint; var theData );
  104.     {you can a new datasize with newdatasize}
  105.  
  106.     procedure   DeleteData_Indexe (Const IndexKennStr: array of Const;
  107.                                           Const IndexStr: array of Const;
  108.                                           ID : longint );
  109.     {you get the id for the actual record with "Datenid"}
  110.  
  111.     procedure   DeleteDataWithIndex( Const IndexKennStr: String;IndexStr: String);
  112.  
  113.  
  114.     procedure   ChangeIndex (Const IndexKennStr: String;
  115.                              IndexStrold,IndexStrNeu: String);
  116.  
  117.     PROCEDURE   GetStatistik (var SL : TStringList);
  118.  
  119.     property DatenID : longint;
  120.  
  121.  
  122.     Function    addStream (var id :longint;Stream : TStream ) : Boolean;
  123.     Function    ReadStream  ( id :longint;Stream : TStream ) : Boolean;
  124.  
  125.  
  126.  
  127.     property ReorgMax :longint;
  128.   published
  129.     { Published-Deklarationen }
  130.  
  131.  
  132.     property DataBaseName: string;
  133.     property DataBaseDir: string;
  134.     property CreateonFail:Boolean;
  135.     property Active:Boolean;
  136.     property DestroyFile:Boolean;
  137.     property OnReorg: TReorgEvent;
  138.     property OnCreate: TNotifyEvent;
  139.  
  140.   end;
  141.  
  142.  
  143.  
  144. implementation
  145.  
  146.  
  147.